package com.alibaba.dubbo.demo.consumer;

import com.alibaba.dubbo.common.beanutil.JavaBeanDescriptor;
import com.alibaba.dubbo.common.beanutil.JavaBeanSerializeUtil;
import com.alibaba.dubbo.demo.Student;
import com.alibaba.dubbo.rpc.service.GenericService;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author zhangsulei
 *
 */
public class Consumer9 {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/dubbo-demo-consumer.xml"});
        context.start();
        GenericService demoService = (GenericService) context.getBean("demoService9"); // get remote service proxy

        Student st = new Student();
    	st.setName("zsl");
    	st.setAge(10);
    	JavaBeanDescriptor param = JavaBeanSerializeUtil.serialize(st);
    	Object st2 = demoService.$invoke("sayHello", new String[]{"com.alibaba.dubbo.demo.Student"}, new Object[]{param});
    	System.out.println(JavaBeanSerializeUtil.deserialize((JavaBeanDescriptor)st2));
    }
}
